import os


class Config:
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'your-secret-key-here'
    SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or 'sqlite:///recommendations.db'
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # 推荐系统配置
    RECOMMENDATION_SYSTEM = {
        'sample_ratio': float(os.environ.get('SAMPLE_RATIO', 0.1)),
        'fast_mode': os.environ.get('FAST_MODE', 'True').lower() == 'true',
        'model_cache_path': os.environ.get('MODEL_CACHE_PATH', 'models/'),
        'data_path': os.environ.get('DATA_PATH', 'data/merged_df.csv')
    }

    # 分页配置
    MOVIES_PER_PAGE = int(os.environ.get('MOVIES_PER_PAGE', 12))
    RECOMMENDATIONS_PER_PAGE = int(os.environ.get('RECOMMENDATIONS_PER_PAGE', 10))

    # 缓存配置
    CACHE_TYPE = os.environ.get('CACHE_TYPE', 'simple')
    CACHE_DEFAULT_TIMEOUT = int(os.environ.get('CACHE_DEFAULT_TIMEOUT', 300))


class DevelopmentConfig(Config):
    DEBUG = True


class ProductionConfig(Config):
    DEBUG = False


config = {
    'development': DevelopmentConfig,
    'production': ProductionConfig,
    'default': DevelopmentConfig
}